package com.admin.boot.common.utils;

import cn.dev33.satoken.secure.SaSecureUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @version v3.0
 * @Description: TODO
 * @author: jeecg-boot
 * @date: 2024-03-04
 */
@Component
public class PasswordUtil {


    public static String privateKey ;


    public static String publicKey;

    @Value("${password.publicKey}")
    public void setPublicKey(String publicKey){
        PasswordUtil.publicKey = publicKey;
    }

    @Value("${password.privateKey}")
    public void setPrivateKey(String privateKey){
        PasswordUtil.privateKey = privateKey;
    }

    public static String encrypt(String password){
        return SaSecureUtil.rsaEncryptByPublic(publicKey,password);

    }

    public static String decrypt(String password){
        return SaSecureUtil.rsaDecryptByPrivate(privateKey,password);
    }


}
